var my_vue;
$(function() {
	$("#left").load("../common/gover-left.html");
	my_vue = new Vue({
		el: '#vue_info',
		data: {

		},
		methods: {
			confirmData: function() {
				var data = $("#myinput").val();
				
				if(data != '' && data != null) {
					if(data.trim() != '') {
						window.location.href = "scannerResult.html?preCode="+data;
					} else {
						showRedMsg("", "请输入您要查询的告知单号");
					}
				} else {
					showRedMsg("", "请输入您要查询的告知单号")
				}
			}	
		},
		ready: function() {
			//初始化获得总页面数和列表数据
			getData();
			var url="../up/index.html";
			windowOpen(url);
		}
	});
})
//获取扫码结果
function getData(){
	 $.ajax({
         url:device.readBrcode,
         async:true,
         type:'get',
         dataType :'json',
         success : function(result) {
             if(result.success && result.data!='' ){
            	 	doMask();
            	 	var preCode = result.data.substring(result.data.lastIndexOf("=")+1,result.data.length);
            	 	$("#myinput").val(preCode);
            	 	my_vue.confirmData();
             }else if(!result.success){
            	 getData();
             }else{
            	 showRedMsg('',"未识别,请重新扫码");
            	 getData();
             }
             return;
         },
         error : function(){
         	showRedMsg('','操作失败，请退出后重试');
             return false;
         }
     });
}